package com.garyme.hycloud.model;

import lombok.Data;

@Data
public class RespData<T> {
    private Integer code;
    private String msg;
    private T data;
    public RespData(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static <T> RespData<T> success(T data){
        return new RespData<>(200, RespCode.SUCCESS.getMsg(), data);
    }
    public static <T> RespData<T> success(){
        return new RespData<>(RespCode.SUCCESS.getCode(),RespCode.SUCCESS.getMsg(),null);
    }
    public static <T> RespData<T> success(String msg){
        return new RespData<>(RespCode.SUCCESS.getCode(),msg,null);
    }
    public static <T> RespData<T> success(String msg, T data){
        return new RespData<>(RespCode.SUCCESS.getCode(), msg, data);
    }

    public static <T> RespData<T> fail(String msg){
        return new RespData<>(RespCode.FAIL.getCode(), msg, null);
    }
    public static <T> RespData<T> fail(Integer code, String msg){
        return new RespData<>(code, msg, null);
    }
    public static <T> RespData<T> fail(Integer code, String msg,T data){
        return new RespData<>(code, msg, data);
    }
}
